package com.lzx.iteam.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.lzx.iteam.R;
import com.lzx.iteam.SalaryFieldEditActivity;
import com.lzx.iteam.bean.SalaryFieldBean;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * **********************************
 * User: zhangshuai
 * Date: 2017年 01月 10日
 * Time: 下午3:43
 *
 * @QQ : 1234567890
 * **********************************
 */
public class SalaryFieldEditAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<SalaryFieldBean> mDatas;

    public SalaryFieldEditAdapter(Context mContext, ArrayList<SalaryFieldBean> mDatas) {
        this.mContext = mContext;
        this.mDatas = mDatas;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        convertView = LayoutInflater.from(mContext).inflate(R.layout.vote_item_layout,null);
        ImageView delete = (ImageView) convertView.findViewById(R.id.vote_item_iv);
        TextView name = (TextView) convertView.findViewById(R.id.vote_item_tv_title);
        EditText content = (EditText) convertView.findViewById(R.id.vote_item_et_content);
        View line = convertView.findViewById(R.id.item_line);
        line.setVisibility(View.GONE);

        SalaryFieldBean bean = mDatas.get(position);
        name.setText("字段" + (position + 1) + ": ");
        content.setText(bean.getName());

        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ((SalaryFieldEditActivity)mContext).deleteField(position);
            }
        });
        return convertView;
    }
}
